import os
import sys

sys.path.insert(0, '/Users/mac/PycharmProjects/opwf_project/opwf')
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'opwf.settings')

import django

django.setup()

from users.models import *

# 修改权限
user = User.objects.get(id=2)
# print(user.role.authorization.all())
# user.role.authorization.add(2,4)
# print(user.role.authorization.all())
#
# user.role.authorization.remove(2,4)
# print(user.role.authorization.all())
# auth = Authorization.objects.get(id=2)
# user.role.authorization.add(auth)
# print(user.role.authorization.all())


path = '/user/'
method = 'GET'

auth_list = []

for auth in user.role.authorization.all():
    s = '%s_%s' % (auth.motheds, auth.url)
    auth_list.append(s)

print(auth_list)

now_auth = '%s_%s' % (method.lower(), path)
print(now_auth)
print(now_auth in auth_list)
